package xginxnote

import (
	"encoding/json"

	"gitee.com/xiaoyutab/xgotool/optional/xnote"
	"gitee.com/xiaoyutab/xgotool/xgin"
	"gitee.com/xiaoyutab/xgotool/xstring"
	"github.com/gin-gonic/gin"
)

// 获取分页列表数据
//
//	GET	/menu.get
func menuGet(c *gin.Context) *xgin.Response {
	type fid_struct struct {
		Fid json.Number `json:"fid" form:"fid"` // 上级栏目ID
	}
	temp := fid_struct{}
	if err := xgin.Bind(c, &temp); err != nil {
		return xgin.Resp().Error(err)
	}
	menu, err := xnote.GetMenu(c.GetUint("uid"), xstring.JUint(temp.Fid))
	if err != nil {
		return xgin.Resp().Error(err)
	}
	return xgin.Resp().NoPage(c, menu, len(menu))
}
